﻿using System;
using IdentityServer4.Models;
using System.Collections.Generic;


namespace WYFast.IdentityServer
{

    public class Id4Config
    {

        //所有可以访问的Resource
        public static IEnumerable<ApiResource> GetResources()
        {
            return new List<ApiResource>
            {
                new ApiResource("api","My Api")
            };
        }

        public static IEnumerable<Scope> GetScopes()
        {
            return new List<Scope>
            {
                new Scope
                {
                    Name = "zeroapi",
                    Description = "LineZero ASP.NET Core Web API"
                }
            };
        }

        // scopes define the resources in your system
        public static IEnumerable<IdentityResource> GetIdentityResources()
        {
            return new List<IdentityResource>
            {
                new IdentityResources.OpenId(),
                new IdentityResources.Profile(),
            };
        }


        public static IEnumerable<Client> GetClients()
        {
            return new List<Client>
            {
                new Client
                {
                    ClientId = "client",
                    ClientName = "MVC Client",
                    
                    //使用clientid / secret进行身份验证

                    AllowedGrantTypes= GrantTypes.ClientCredentials,//模式：最简单的模式
                    // 加密验证
                    ClientSecrets = new List<Secret>
                    {
                        new Secret("secret".Sha256())
                    },

                    // client可以访问的范围，在上面定义的。
                    AllowedScopes = new List<string>
                    {
                        "api"
                    }
                }
            };
        }
    }
}
